/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#include "AtomPath.h"

namespace liba
{
namespace animate
{

std::string AtomPath::get_str()const
{
	std::string ret;
	if( empty() )
		return ret;
	const_iterator cit = begin();
	for( ; cit != end() - 1; ++cit )
	{
		ret.append( cit->get_str() );
		ret.append( 1, separator );
	}
	ret.append( cit->get_str() );
	return ret;
}

void AtomPath::assign(const char * beg, const char * en)
{
	clear();
	const char * ptr = beg;
	while( ptr != en )
	{
		const char * ptr2 = ptr;
		while( ptr2 != en && *ptr2 != separator )
			++ptr2;
		push_back( Atom( ptr, ptr2 ) );
		ptr = ptr2;
		if( ptr2 != en )
			++ptr;
	}
}

void AtomPath::assign(const char * str)
{
	const char * en = str + strlen( str );
	assign(str, en);
}

} // namespace animate
} // namespace liba

